package com.haoshuang.zhouzhoubang.ui.page.mine.wallet.frozen

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.haoshuang.zhouzhoubang.model.bean.DepositBean
import com.haoshuang.zhouzhoubang.model.bean.WalletBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.ResponseBean
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class FrozenAmountViewModel : BaseViewModel() {
    /**
     * 获取钱包主页数据
     */
    val getWalletDetailData = StatefulMutableLiveData<ResponseBean<WalletBean>>()
    fun getWalletDetail() = netRequest {
        start { getWalletDetailData.value = StateData.Loading }
        request { ApiRepo.getWalletDetail()  }
        success { getWalletDetailData.value = StateData.Success(it) }
        error { code, msg ->
            getWalletDetailData.value = StateData.Error(code, msg)
        }
    }

    /**
     * 冻结保证金大类列表
     */
    val getDepositListData = StatefulMutableLiveData<ResponseBean<MutableList<DepositBean>>>()
    fun getDepositList(is_deposit: Int) = netRequest {
        start { getDepositListData.value = StateData.Loading }
        request { ApiRepo.getDepositList(is_deposit)  }
        success { getDepositListData.value = StateData.Success(it) }
        error { code, msg ->
            getDepositListData.value = StateData.Error(code, msg)
        }
    }
}